using HCore.IOC.Beans.Factory.Attribute.Attr;
using HCore.IOC.Context.Event;
using HCore.IOC.Context.Event.Attr;
using HCore.IOC.Context.Stereotype;
using HCore.Tests.Runtime.DianDianDian.Event;
using HCore.Tests.Runtime.DianDianDian.Model;
using HCore.Tests.Runtime.ShootingEditor2D.Scripts.Support.CommandQuery;

namespace HCore.Tests.Runtime.DianDianDian.Command
{
    public class MissCommand : ICommand
    {
    }

    [Component]
    public class MissCommandReceiver : EventPublisher
    {
        [Autowired] private IGameModel mGameModel;

        [EventListener]
        public void OnMissCommand(MissCommand command)
        {
            // 点击背景板，如果生命足够，则不触发 MissEvent，生命减一
            if (mGameModel.Life > 0) mGameModel.Life--;
            else PublishEvent(new MissEvent());
        }
    }
}